package guowei.gulistorage.storage.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import guowei.common.utils.PageUtils;
import guowei.common.utils.Query;

import guowei.gulistorage.storage.dao.WareOrderTaskDetailDao;
import guowei.gulistorage.storage.entity.WareOrderTaskDetailEntity;
import guowei.gulistorage.storage.service.WareOrderTaskDetailService;


@Service("wareOrderTaskDetailService")
public class WareOrderTaskDetailServiceImpl extends ServiceImpl<WareOrderTaskDetailDao, WareOrderTaskDetailEntity> implements WareOrderTaskDetailService {

    @Autowired
    private WareOrderTaskDetailDao wareOrderTaskDetailDao;

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<WareOrderTaskDetailEntity> page = this.page(
                new Query<WareOrderTaskDetailEntity>().getPage(params),
                new QueryWrapper<WareOrderTaskDetailEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public void rollbackMd(Long skuId, Long wareId, Integer skuNum,Long detailId) {
        wareOrderTaskDetailDao.rollbackmd(skuId,wareId,skuNum);
        //回滚库存锁定成功后，需要改变库存详情单锁定状态
        WareOrderTaskDetailEntity entity = new WareOrderTaskDetailEntity();
        entity.setId(detailId);
        entity.setLockStatus(2);    //有未解锁变为已解锁状态
        wareOrderTaskDetailDao.updateById(entity);
    }

}